<?php
header ( "Content-Type:text/html; charset=utf-8" );
include '../public/db.php';
@$name=$_REQUEST['name'];
@$psw=$_REQUEST['psw'];
$classid=5;
if(empty($name)|empty($psw)){
	echo '{"success":false,"msg":"你填写的信息不完整！"}';
}else{
	$person = select('select * from user where name=:name',array('name'=>$name));
	if(empty($person)){
		insert('insert into user values(name=:name,password=:password,classId=:classid)',
		array('name'=>$name,'password'=>$psw,classid=>$classid));
		$insert = select('select * from user where name=:name',array('name'=>$name));
		if (empty($insert) ){
			echo '{"success":false,"msg":"注册失败，未知错误！"}';
		}else{
			echo '{"success":true,"msg":"注册成功，请登录。"}';
		}
	}else{
		echo '{"success":false,"msg":"该用户已存在！"}';
	}
}